﻿/***************************************************************************************************/
/* @date on 2020-9-2 15:13:30                                                                      */
/* @author Xie Jian                                                                                */
/* @email 190954950@qq.com                                                                         */
/* @describe 代码着色                                                                              */
/***************************************************************************************************/
using CodeColorHtml.LanguageCulour;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices.ComTypes;
using System.Text;
using System.Threading.Tasks;
using System.Transactions;

namespace CodeColorHtml
{
    /// <summary>
    /// 着色器
    /// </summary>
    internal class Colour
    {
        /// <summary>
        /// 代码
        /// </summary>
        private string _code;
        /// <summary>
        /// 代码类型
        /// </summary>
        private CodeType _codeType;

        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="code">代码</param>
        /// <param name="codeType">代码类型</param>
        internal Colour(string code, CodeType codeType)
        {
            this._code = code;
            this._codeType = codeType;
        }

        /// <summary>
        /// 获取着色后代码
        /// </summary>
        /// <returns></returns>
        internal string GetCodeColorHtml()
        {
            string codeHtml = _code;
            switch (_codeType)
            {
                case CodeType.C:
                    break;
                case CodeType.CPlusPlus:
                    break;
                case CodeType.CSharp:
                    CoulourCSharp csharp = new CoulourCSharp(_code);
                    codeHtml = csharp.GetCodeColorHtml();
                    break;
                case CodeType.Css:
                    break;
                case CodeType.Html:
                    break;
                case CodeType.Java:
                    break;
                case CodeType.JavaScript:
                    CoulourJavaScript javaScript = new CoulourJavaScript(_code);
                    codeHtml = javaScript.GetCodeColorHtml();
                    break;
                case CodeType.Sql:
                    CoulourSql sql = new CoulourSql(_code);
                    codeHtml = sql.GetCodeColorHtml();
                    break;
                case CodeType.Xml:
                    break;
                case CodeType.Shell:
                    CoulourShell shell = new CoulourShell(_code);
                    codeHtml = shell.GetCodeColorHtml();
                    break;
                default:
                    break;
            }
            return codeHtml;
        }
        
    }
    
}
